package com.shadowtorcher.stdisk.util;

import com.shadowtorcher.soulknife.exception.BeanConfigErrorException;
import com.shadowtorcher.stdisk.bean.UserBean;

import java.sql.SQLException;

public class SpaceGetter {
    private UserBean user;

    public SpaceGetter(UserBean user) {
        this.user = user;
    }

    public long getUsed() {
        return user.getUsedSpace();
    }

    public long getTotal() throws SQLException {
        long size = 0;
        try {
            Permission permission = new Permission(user.getPermissionID());
            size = Long.parseLong(permission.get("size"));
        } catch (BeanConfigErrorException e) {
            e.printStackTrace();
        }
        return size;
    }
}
